package com.thb.pay.controller;


import com.thb.pay.api.sys.SysResourceServiceApi;
import com.thb.pay.core.utils.PageResult;
import com.thb.pay.service.SysResourceService;
import com.thb.pay.vo.req.SysResourcePageReq;
import com.thb.pay.vo.req.SysResourceReq;
import com.thb.pay.vo.resp.SysResourceVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 * 系统-资源表 前端控制器
 * </p>
 *
 * @author lucky
 * @since 2019-07-21
 */
@RestController
public class SysResourceController implements SysResourceServiceApi {

    @Autowired
    private SysResourceService sysResourceService;

    @Override
    public PageResult<SysResourceVo> findPage(@RequestBody SysResourcePageReq pageReq) {
        return sysResourceService.findPage(pageReq);
    }

    @Override
    public List<SysResourceVo> findListByParentId(@RequestParam("parentId") Long parentId) {
        return sysResourceService.findListByParentId(parentId);
    }

    @Override
    public List<SysResourceVo> findListBySystemType(@RequestParam("systemType") Integer systemType) {
        return sysResourceService.findListBySystemType(systemType);
    }

    @Override
    public SysResourceVo getByPermissionCode(@RequestParam("code") String code) {
        return sysResourceService.getByPermissionCode(code);
    }

    @Override
    public void save(@RequestBody SysResourceReq resourceReq) {
        sysResourceService.save(resourceReq);
    }

    @Override
    public void update(@RequestBody SysResourceReq resourceReq) {
        sysResourceService.update(resourceReq);
    }

    @Override
    public void deleteBatchResourceIds(@RequestBody List<Long> resourceIds) {
        sysResourceService.deleteBatchIds(resourceIds);
    }

    @Override
    public List<SysResourceVo> findListByUserId(@RequestParam("userId") Long userId) {
        return sysResourceService.findListByUserId(userId);
    }
}
